package com.example.yichuangyun.mvvm.ui.activity.order;

import android.os.Bundle;

import com.example.yichuangyun.R;
import com.example.yichuangyun.databinding.ActivityOrderResultBinding;
import com.example.yichuangyun.mvvm.base.BaseActivity;
import com.example.yichuangyun.mvvm.base.BaseViewModel;
import com.example.yichuangyun.utils.JumpIntent;

import io.reactivex.functions.Consumer;

/**
 * 下单结果页
 */
public class OrderResultActivity extends BaseActivity<ActivityOrderResultBinding, BaseViewModel> {

    @Override
    protected BaseViewModel bindModel() {
        return getViewModel(this, BaseViewModel.class);
    }

    @Override
    protected void initInject() {
        getActivityComponent().inject(this);
    }

    @Override
    protected void initData() {
        initTitleBar(getString(R.string.create_order_success));
        Bundle bundle = getIntent().getExtras();
        initTitleBar(getString(bundle == null ? R.string.create_order_success : R.string.create_order_error));
        binding.ivResult.setImageResource(bundle == null ? R.mipmap.icon_order_success : R.mipmap.icon_order_error);
        binding.btn.setText(getString(bundle == null ? R.string.look_order : R.string.create_order_again));
        viewModel.onDelayClick(binding.btn, o -> {
            if (bundle == null) {
                JumpIntent.jump(this, OrderListActivity.class, true);
            } else {
                finish();
            }
        });
    }
}